using System;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Security;
namespace Os.WebUI.Models
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
	public sealed class ValidatePasswordLengthAttribute : ValidationAttribute
	{
		private const string _defaultErrorMessage = "'{0}' precisa ser maior que {1} caracteres.";
		private readonly int _minCharacters = Membership.Provider.MinRequiredPasswordLength;
		public ValidatePasswordLengthAttribute() : base("'{0}' precisa ser maior que {1} caracteres.")
		{
		}
		public override string FormatErrorMessage(string name)
		{
			return string.Format(CultureInfo.CurrentUICulture, ErrorMessageString, new object[]
			{
				name, 
				this._minCharacters
			});
		}
		public override bool IsValid(object value)
		{
			string text = value as string;
			return text != null && text.Length >= this._minCharacters;
		}
	}
}
